#include <stdio.h>
#include <string.h>

void cha(int ch1[],int sz)
{
	int k;
	int left=0;
	int right=sz-1;
	int mid;
	printf("请输入要查找的值:\n");
	scanf("%d",&k);
	while(left<=right)
	{
		mid=(left+right)/2;
		if(ch1[mid]<k)
		left=mid+1;
		else if(ch1[mid]>k)
		right=mid-1;
		else
		{
			printf("k在ch[]中的下标是%d\n",mid);
			return;
		}
	}
	printf("没有要找的数");
	return;
	
}

int main()
{
	int ch[]={0,1,2,3,4,5,6,7,8,9};
	int sz=sizeof(ch)/sizeof(ch[0]);
	cha(ch,sz);
	return 0;
}